package com.zhangjm.dao;

import com.zhangjm.pojo.Citys;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CitysDao extends JpaRepository<Citys, Integer> {


    /**
     * 查询所有的一级菜单
     * @return
     */
    @Query(value = "select * from  city  where pid = 0 order by id asc",nativeQuery = true)
    public List<Citys> getAllCitysOfFirst();


    /**
     * 根据pid查询子菜单
     * @param pid
     * @return
     */
    @Query(value = "select * from  city  where pid = :pid order by id asc",nativeQuery = true)
    public List<Citys> getChildrenListByPid(@Param("pid") Integer pid);
}
